package com.x.attendance.core.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import com.x.base.core.entity.annotation.*;
import org.apache.openjpa.persistence.jdbc.Index;

import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.project.annotation.FieldDescribe;

/**
 * 指纹信息实体类
 * @author Manus AI
 */
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.Fingerprint.table, uniqueConstraints = {
		@UniqueConstraint(name = PersistenceProperties.Fingerprint.table + JpaObject.IndexNameMiddle
				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Fingerprint extends SliceJpaObject {

	private static final long serialVersionUID = 1325197931747463980L;
	private static final String TABLE = PersistenceProperties.Fingerprint.table;

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	@FieldDescribe("数据库主键,自动生成.")
	@Id
	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
	private String id = createId();

	@Override
	public void onPersist() {
	}

	/*
	 * =============================================================================
	 * ===== 以下为指纹信息字段
	 * =============================================================================
	 */

	public static final String employeeId_FIELDNAME = "employeeId";
	@FieldDescribe("员工ID")
	@Index(name = TABLE + IndexNameMiddle + employeeId_FIELDNAME)
	@Column(length = length_id, name = ColumnNamePrefix + employeeId_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String employeeId;

	public static final String fingerIndex_FIELDNAME = "fingerIndex";
	@FieldDescribe("手指编号(1-10)")
	@Column(name = ColumnNamePrefix + fingerIndex_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private Integer fingerIndex;

	public static final String template_FIELDNAME = "template";
	@FieldDescribe("指纹模板")
	@Lob
	@Column(name = ColumnNamePrefix + template_FIELDNAME)
	private byte[] template;

	public static final String image_FIELDNAME = "image";
	@FieldDescribe("指纹图像")
	@Lob
	@Column(name = ColumnNamePrefix + image_FIELDNAME)
	private byte[] image;

	public static final String quality_FIELDNAME = "quality";
	@FieldDescribe("指纹质量")
	@Column(name = ColumnNamePrefix + quality_FIELDNAME)
	private Integer quality;

	public static final String collectionTime_FIELDNAME = "collectionTime";
	@FieldDescribe("采集时间")
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = ColumnNamePrefix + collectionTime_FIELDNAME)
	private Date collectionTime;

	// Getters and Setters
	public String getEmployeeId() {
		return employeeId;
	}

	public void setEmployeeId(String employeeId) {
		this.employeeId = employeeId;
	}

	public Integer getFingerIndex() {
		return fingerIndex;
	}

	public void setFingerIndex(Integer fingerIndex) {
		this.fingerIndex = fingerIndex;
	}

	public byte[] getTemplate() {
		return template;
	}

	public void setTemplate(byte[] template) {
		this.template = template;
	}

	public byte[] getImage() {
		return image;
	}

	public void setImage(byte[] image) {
		this.image = image;
	}

	public Integer getQuality() {
		return quality;
	}

	public void setQuality(Integer quality) {
		this.quality = quality;
	}

	public Date getCollectionTime() {
		return collectionTime;
	}

	public void setCollectionTime(Date collectionTime) {
		this.collectionTime = collectionTime;
	}
}

